Skip to content

feat(providers): add Claude CLI provider (OAuth-backed, text-only)#8

Open
arakakileo wants to merge 5 commits into
cosmicstack-labs:mainfrom
arakakileo:feat/claude-cli-provider
Open

feat(providers): add Claude CLI provider (OAuth-backed, text-only)#8
arakakileo wants to merge 5 commits into
cosmicstack-labs:mainfrom
arakakileo:feat/claude-cli-provider

Conversation

@arakakileo
Copy link
Copy Markdown

Summary

  • New ClaudeCliProvider that rides the local claude CLI's OAuth session (Claude Max/Pro) — no Anthropic API key required
  • Implements LanguageModelV1 so it plugs into the same streamText / generateText flow as @ai-sdk/anthropic
  • Text-only by design: built-in CLI tools disabled via --tools ""; callers passing mode.tools get a warning and proceed without tool calls

Changes

  • src/providers/claude-cli.ts — new provider (spawns claude -p --output-format stream-json, parses events, drains stdout on 'close' to avoid racing pending data, kills child on stream cancel/abort)
  • src/providers/registry.ts — instantiation branch for claudeCli
  • src/providers/index.ts — re-export
  • src/utils/config.tsclaudeCli block in defaults + ProviderName; isProviderConfigured skips apiKey check (auth comes from CLI OAuth)
  • src/utils/provider-models.tsopus / sonnet / haiku as preferred aliases for the model picker
  • package-lock.json — resync with optional better-sqlite3 + node 20 engines (follow-up to 2f7e5e6 / af1125c)

Limitation (documented in file header)

claude -p doesn't accept caller-defined tools — only its own built-ins (Bash, Read, Edit, ...). Those are disabled so the adapter is strictly text-generation. Workflows requiring tools (Mercury's scheduled skills) must stay on anthropic / openai.

Env

New env vars (all optional, provider disabled by default):

  • CLAUDE_CLI_ENABLED (default false)
  • CLAUDE_CLI_PATH (default claude)
  • CLAUDE_CLI_MODEL (default opus)

Test plan

  • npm run typecheck — clean
  • npm run build — tsup ESM builds
  • npm test — 20/20 pass
  • Smoke test generateText — returned expected output end-to-end against local claude OAuth session
  • Smoke test streamText — same, via 'close'-based finish path

arakakileo and others added 5 commits April 24, 2026 00:13
Rides the local claude CLI's OAuth session (Claude Max/Pro) instead of
requiring an Anthropic API key. Implements LanguageModelV1 so it plugs
into the same streamText/generateText path as the @ai-sdk/anthropic
provider.

Text-only: built-in CLI tools are disabled via --tools "" so the spawned
claude never executes locally. Callers that pass mode.tools get a warning
and proceed without tool calls — workflows that need tools must use
anthropic (API key) or openai.

- claude-cli.ts: LanguageModelV1 + BaseProvider, stream-json parsing,
  stdout drained on 'close' to avoid racing with pending data
- registry.ts: branch for claudeCli instantiation
- config.ts: claudeCli block in defaults, isProviderConfigured skips
  apiKey check (auth comes from CLI OAuth)
- provider-models.ts: opus/sonnet/haiku as preferred model aliases
…ines

Regenerated after the overrides/engines changes in 2f7e5e6 and af1125c
so CI installs match package.json.
…uledTask

Remove the pre-run channel.send() that emits 'Scheduled task started...' /
'All actions auto-approved for this run.' before every scheduled task
execution. Scheduled tasks still enqueue and execute through
processInternalPrompt(). The heartbeat reminder notification block is
unchanged. Logger.info at task entry preserved for server-side diagnostics.

Refs: paperclip task aeae06c7-be9a-4330-bb5b-341701f47f91 (LEOA-860)
7 Vitest cases proving LEOA-859 regression safety:
- No-op scheduled task sends zero startup notifications
- Actionable task still invokes runtime handler correctly
- Task failure propagates error without startup notification
- Multiple consecutive no-ops accumulate zero notifications
- Skill-based tasks also silent
- Prompt construction contains no startup banner strings

Refs: LEOA-861
Refs: paperclip task LEOA-861

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant